package num11;

import java.util.ArrayList;
import java.util.HashSet;

public class Leecode234 {
    public class ListNode {
     int val;
     ListNode next;
     ListNode() {}
     ListNode(int val) { this.val = val; }
      ListNode(int val, ListNode next) { this.val = val; this.next = next; }
  }
    public boolean isPalindrome(ListNode head) {
        ArrayList<Integer> arr = new ArrayList<>();
        while (head != null){
            arr.add(head.val);
            head = head.next;
        }
        int right = arr.size()-1;
        int left = 0;
        while (right > left){
            if ( !arr.get(right).equals(arr.get(left))){
               return false;
            }
            left++;
            right--;

        }
        return true;


    }
}
